Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build for use within a SQLite3 loadable extension #320

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mlin
Copy link

@mlin mlin commented Jan 23, 2021

Greetings @SRombauts or maintainer whom it may concern

I have an interesting use case in which I want to use SQLiteCpp's convenient API within the implementation of a SQLite3 loadable extension. There are three bits needed,

  1. Construct a SQLite::Database object to wrap a given sqlite3* connection (passed to us as the extension is loaded) instead of opening a new one. Straightforward, but check my work?
  2. The SQLiteCpp object code must be built against a "version" of the SQLite3 API provided by sqlite3ext.h instead of sqlite3.h, with reference to an extern symbol needed to make that work (usually hidden behind the SQLITE_EXTENSION_INIT1 macro). Here activated by the new SQLITECPP_IN_EXTENSION CMake option.
  3. The SQLiteCpp library must not itself link SQLite3, since whatever program loads the extension will necessarily already have it resident. In particular, the main program could have SQLite3 statically linked, and extremely confusing things are liable to happen if the extension also dynamically links a different version of SQLite3. Here this is also controlled by SQLITECPP_IN_EXTENSION

With the enclosed example, it all seems to work nicely. Thanks for consideration!

@mlin mlin force-pushed the use-in-loadable-extension branch from 8f42f71 to 49a568f Compare January 23, 2021 08:21
@mlin mlin changed the title Build option for use within a SQLite3 loadable extension Build for use within a SQLite3 loadable extension Jan 23, 2021
@coveralls
Copy link

coveralls commented Jan 23, 2021

Coverage Status

Coverage remained the same at 100.0% when pulling 6d089fc on mlin:use-in-loadable-extension into 0c46d86 on SRombauts:master.

@mlin mlin force-pushed the use-in-loadable-extension branch from 78946be to 6d089fc Compare May 31, 2021 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants